package com.ruoyi.ruoyiqywechat.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.ruoyiqywechat.domain.MembershipPlanNew;
import com.ruoyi.ruoyiqywechat.service.IMembershipPlanNewService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 会员套餐Controller
 *
 * @author 好六
 * @date 2025-10-10
 */
@RestController
@RequestMapping("/membershipPlanNew")
public class MembershipPlanNewController extends BaseController
{
    @Autowired
    private IMembershipPlanNewService membershipPlanNewService;

    /**
     * 查询会员套餐列表
     */
  //("ruoyiqywechat:membershipPlanNew:list")
    @GetMapping("/list")
    public TableDataInfo list(MembershipPlanNew membershipPlanNew)
    {
        startPage();
        List<MembershipPlanNew> list = membershipPlanNewService.selectMembershipPlanNewList(membershipPlanNew);
        return getDataTable(list);
    }

    /**
     * 导出会员套餐列表
     */
  //("ruoyiqywechat:membershipPlanNew:export")
    @Log(title = "会员套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MembershipPlanNew membershipPlanNew)
    {
        List<MembershipPlanNew> list = membershipPlanNewService.selectMembershipPlanNewList(membershipPlanNew);
        ExcelUtil<MembershipPlanNew> util = new ExcelUtil<MembershipPlanNew>(MembershipPlanNew.class);
        util.exportExcel(response, list, "会员套餐数据");
    }

    /**
     * 获取会员套餐详细信息
     */
  //("ruoyiqywechat:membershipPlanNew:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(membershipPlanNewService.selectMembershipPlanNewById(id));
    }

    /**
     * 新增会员套餐
     */

    @Log(title = "会员套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MembershipPlanNew membershipPlanNew)
    {
        return toAjax(membershipPlanNewService.insertMembershipPlanNew(membershipPlanNew));
    }

    /**
     * 修改会员套餐
     */
  //("ruoyiqywechat:membershipPlanNew:edit")
    @Log(title = "会员套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MembershipPlanNew membershipPlanNew)
    {
        return toAjax(membershipPlanNewService.updateMembershipPlanNew(membershipPlanNew));
    }

    /**
     * 删除会员套餐
     */
  //("ruoyiqywechat:membershipPlanNew:remove")
    @Log(title = "会员套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(membershipPlanNewService.deleteMembershipPlanNewByIds(ids));
    }
}
